package com.example.ccj.u.data;

import androidx.annotation.NonNull;

import java.util.HashMap;
import java.util.Map;

/**
 * 临时数据存储
 * 2023年11月5日18:26:19
 */
public class LinShiCunChu {
    private static final String TAG = "临时数据存储";
    //存储暂时的文件
    private Map<String, Object> data = new HashMap<>();
    private static LinShiCunChu instance;

    public static LinShiCunChu getInstance() {
        if (instance == null) {
            synchronized (LinShiCunChu.class) {
                if (instance == null) {
                    instance = new LinShiCunChu();
                }
            }
        }
        return instance;
    }

    public void save(String id, Object object) {
        data.put(id, object);
    }

    public void remove(@NonNull String id) {
        if (data != null) {
            data.remove(id);
        }
    }

    public Object retrieve(String id) {
        if (data.containsKey(id)) {
            return data.get(id);
        }
        return null;
    }

}
